<?php

namespace app\controller\admin;
use app\BaseController;
use app\exception\UserException;
use edward\captcha\facade\CaptchaApi;

/**
 * 会员登录
 */
class Login extends BaseController
{

    /**
     * 登录接口
     */
    public function login()
    {

        $data = input('post.');
        $check_res = CaptchaApi::check($data['code'], $data['uuid']);
        if(!$check_res){
            throw new UserException('验证码错误');
        }
        $token = \app\common\model\Admin::login($data['username'], $data['password']);
        return success(['token'=>$token]);
    }


}